const { Tab } = require('../../assets/libs/zanui/index');

var app = getApp();
Page(Object.assign({}, Tab, {
  data: {
		cdnUrl: '',
		/* 自定义导航栏参数 */
		loading: false,
		color: '#FFFFFF',
		background: '#FFFFFF',
		show: true,
		animated: false,
		back: true,
		title: "我的订单",
		
		/* 订单筛选 */
		status: -1,//全部
		orderList:[]
  },
	/**
	 * 点击tab切换 
	 */
	 swichNav: function( e ) { 
		var that = this; 
		if( that.data.status === e.target.dataset.status ) {
			return false;
		} else { 
			that.setData( { 
				status: e.target.dataset.status
			})
		}
		that.orderList(that.data.status);
	},
	orderList: function(status){
		var that = this;
		app.request('/addons/cms/wxapp.shop/orderList', {status: status}, function (data, ret) {
		  that.setData({
		    orderList: data,
		  });
		}, function (data, ret) {
			console.log(ret);
		  app.error('服务器错误');
		});
	},
  onLoad: function () {
    var that = this;
		that.orderList(-1);
		that.setData({
			cdnUrl: app.cdnUrl,
		});
  },
  onPullDownRefresh: function () {
		var that = this;
		that.orderList(that.data.status);
	},
  onReachBottom: function () {},
  onShareAppMessage: function () {
    return {
      title: '',
      desc: '',
      path: '/page/index/index'
    }
  }
}))
